package indi.cyh.fastservice.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName CorsConfig
 * @Description TODO
 * @Author CYH
 * @Date 2022/11/30 11:08
 */
// 请求跨域
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Value("${cros.allowedorigins}")
    String[] allowedOrigins;

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //添加映射路径
        CorsRegistration corsRegistration = registry.addMapping("/**")
                //是否发送Cookie
                .allowCredentials(true)
                .allowCredentials(true)
                .allowedOrigins(allowedOrigins)
                .allowedMethods("GET");

    }


}
